import { Inject } from '@nestjs/common';
import * as fs from 'fs/promises'; // 使用 fs/promises 替代 fs
import { WINSTON_LOGGER_TOKEN } from 'src/winston/winston.module';

export class FileUtil {
  
  static async deleteLocalFile(filePath: string): Promise<void> {
    // 拼接文件路径
    try {
      // 使用 fs.unlink 异步删除文件
      await fs.unlink(filePath);
      console.log(`File ${filePath} deleted successfully.`);
    } catch (error) {
      console.error(`Error deleting file ${filePath}: ${error.message}`);
      // 如果需要，可以抛出异常或进行其他错误处理
      throw error;
    }
  }
}
